package com.flea.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Table;

import java.math.BigDecimal;
import java.time.Instant;

/**
 * @author hc24
 * @date 2021.1.21 13:06
 */
@Table
@Data
public class Product {
    @Id
    private Integer id;
    private String name;
    private String desc;
    private String brand;
    private BigDecimal currentPrice;
    private BigDecimal originalPrice;
    private BigDecimal shippingFee;
    private Integer userId;
    private Integer inventory;
    @JsonFormat
    private Instant createTime;
    private Instant updateTime;


    public ProductDoc toDoc() {
        ProductDoc productDoc = new ProductDoc();
        productDoc.setProductId(this.getId());
        productDoc.setName(this.getName());
        productDoc.setDesc(this.getDesc());

        return productDoc;
    }
}
